<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Superpixel Benchmark: lib_eval/io_util.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Superpixel Benchmark
   </div>
   <div id="projectbrief">Superpixel benchmark, tools and algorithms.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_f07c7e2e21621c6454ef07b472f6f1ef.html">lib_eval</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">io_util.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="io__util_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;</div><div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#ifndef IO_UTIL_H</span></div><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#define IO_UTIL_H</span></div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;<span class="preprocessor">#include &lt;map&gt;</span> </div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;<span class="preprocessor">#include &lt;boost/filesystem.hpp&gt;</span></div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;<span class="preprocessor">#include &lt;opencv2/opencv.hpp&gt;</span></div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="preprocessor">#ifndef DIRECTORY_SEPARATOR</span></div><div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;<span class="preprocessor">    #if defined(WIN32) || defined(_WIN32)</span></div><div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="preprocessor">        #define DIRECTORY_SEPARATOR &quot;\\&quot;</span></div><div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;<span class="preprocessor">    #else</span></div><div class="line"><a name="l00045"></a><span class="lineno"><a class="line" href="io__util_8h.html#af1e88bb4b1ff9546e6803eec85e0684c">   45</a></span>&#160;<span class="preprocessor">        #define DIRECTORY_SEPARATOR &quot;/&quot;</span></div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;<span class="preprocessor">    #endif</span></div><div class="line"><a name="l00047"></a><span class="lineno">   47</span>&#160;<span class="preprocessor">#endif</span></div><div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;</div><div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="classIOUtil.html">   52</a></span>&#160;<span class="keyword">class </span><a class="code" href="classIOUtil.html">IOUtil</a> {</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classIOUtil.html#a46bb84fe3409d74aca7b2e9e2699e35e">readMat</a>(boost::filesystem::path file, cv::Mat &amp;mat, std::string field = <span class="stringliteral">&quot;mat&quot;</span>);</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    </div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classIOUtil.html#a446a98fc423c951454037129c46eec14">writeMat</a>(boost::filesystem::path file, <span class="keyword">const</span> cv::Mat&amp; mat, </div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;            std::string field = <span class="stringliteral">&quot;mat&quot;</span>);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    </div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classIOUtil.html#ac6f4ce4f5fbab56c6febfb483e40284c">writeArrayCSV</a>(boost::filesystem::path file, T** array, <span class="keywordtype">int</span> rows, <span class="keywordtype">int</span> cols, </div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;            std::string separator = <span class="stringliteral">&quot;,&quot;</span>, <span class="keywordtype">int</span> precision = 6);</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    </div><div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;    <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classIOUtil.html#ab911811634c83c884c0acbc6b14c1321">writeMatCSV</a>(boost::filesystem::path file, <span class="keyword">const</span> cv::Mat&amp; mat, </div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;            std::string separator = <span class="stringliteral">&quot;,&quot;</span>, <span class="keywordtype">int</span> precision = 6);</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    </div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classIOUtil.html#ad1b3f8c15c94c95a1e41d94bd651f3c8">readMatCSVInt</a>(boost::filesystem::path file, cv::Mat &amp;result);</div><div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    </div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classIOUtil.html#ad1b3f8c15c94c95a1e41d94bd651f3c8">readMatCSVInt</a>(boost::filesystem::path file, <span class="keywordtype">int</span> rows, <span class="keywordtype">int</span> cols, cv::Mat &amp;result);</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;    </div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classIOUtil.html#a301206e86594f7eafa2a561bef4c1eaf">readMatCSVFloat</a>(boost::filesystem::path file, cv::Mat &amp;result);</div><div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    </div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classIOUtil.html#a98f41161281f66a907466baae0000483">readCSVHeaderString</a>(boost::filesystem::path file, std::vector&lt;std::string&gt; &amp;header);</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    </div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classIOUtil.html#a9e7c777463186a87bc2cfe24396dba41">readCSVSummary</a>(boost::filesystem::path file, std::vector&lt;std::string&gt;&amp; row_headers, </div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;            std::vector&lt;std::string&gt;&amp; col_headers, cv::Mat &amp;data);</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    </div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classIOUtil.html#a8fa12c1903f0a602a0cb45748510c9f2">listSubdirectories</a>(boost::filesystem::path directory, </div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;            std::multimap&lt;std::string, boost::filesystem::path&gt; subdirectories);</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;    </div><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classIOUtil.html#a9a2042854799a9885a77767b359c7b5c">readDirectory</a>(boost::filesystem::path directory, </div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;        std::vector&lt;std::string&gt; extensions, </div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;        std::multimap&lt;std::string, boost::filesystem::path&gt; &amp;files,</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;        std::string prefix = <span class="stringliteral">&quot;&quot;</span>, std::string suffix = <span class="stringliteral">&quot;&quot;</span>,</div><div class="line"><a name="l00161"></a><span class="lineno">  161</span>&#160;        std::vector&lt;std::string&gt; exclude = std::vector&lt;std::string&gt;{});</div><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;        </div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classIOUtil.html#a9a2042854799a9885a77767b359c7b5c">readDirectory</a>(boost::filesystem::path directory,</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;        std::multimap&lt;std::string, boost::filesystem::path&gt; &amp;files,</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;        std::string prefix = <span class="stringliteral">&quot;&quot;</span>, std::string suffix = <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;    </div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classIOUtil.html#aa5af93a2369deca17e146b1a070101e4">getImageExtensions</a>(std::vector&lt;std::string&gt; &amp;extensions);</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;    </div><div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classIOUtil.html#a9a6b45f5d8ea7135fb612f50042deab7">getTxtExtensions</a>(std::vector&lt;std::string&gt; &amp;extensions);</div><div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;    </div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classIOUtil.html#a16c52e4be85d55d18d86e2389c8642f0">getCSVExtensions</a>(std::vector&lt;std::string&gt; &amp;extensions);</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;    </div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;};</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;<span class="preprocessor">#endif  </span><span class="comment">/* IO_UTIL_H */</span><span class="preprocessor"></span></div><div class="ttc" id="classIOUtil_html_a446a98fc423c951454037129c46eec14"><div class="ttname"><a href="classIOUtil.html#a446a98fc423c951454037129c46eec14">IOUtil::writeMat</a></div><div class="ttdeci">static int writeMat(boost::filesystem::path file, const cv::Mat &amp;mat, std::string field=&quot;mat&quot;)</div><div class="ttdoc">Write a matrix to the given file. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:59</div></div>
<div class="ttc" id="classIOUtil_html_aa5af93a2369deca17e146b1a070101e4"><div class="ttname"><a href="classIOUtil.html#aa5af93a2369deca17e146b1a070101e4">IOUtil::getImageExtensions</a></div><div class="ttdeci">static void getImageExtensions(std::vector&lt; std::string &gt; &amp;extensions)</div><div class="ttdoc">Gets a vector containing common extensions for images. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:265</div></div>
<div class="ttc" id="classIOUtil_html_ad1b3f8c15c94c95a1e41d94bd651f3c8"><div class="ttname"><a href="classIOUtil.html#ad1b3f8c15c94c95a1e41d94bd651f3c8">IOUtil::readMatCSVInt</a></div><div class="ttdeci">static int readMatCSVInt(boost::filesystem::path file, cv::Mat &amp;result)</div><div class="ttdoc">Read CSV file into matrix. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:301</div></div>
<div class="ttc" id="classIOUtil_html_ac6f4ce4f5fbab56c6febfb483e40284c"><div class="ttname"><a href="classIOUtil.html#ac6f4ce4f5fbab56c6febfb483e40284c">IOUtil::writeArrayCSV</a></div><div class="ttdeci">static int writeArrayCSV(boost::filesystem::path file, T **array, int rows, int cols, std::string separator=&quot;,&quot;, int precision=6)</div><div class="ttdoc">Write two dimensional array to CSV file. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:75</div></div>
<div class="ttc" id="classIOUtil_html_a98f41161281f66a907466baae0000483"><div class="ttname"><a href="classIOUtil.html#a98f41161281f66a907466baae0000483">IOUtil::readCSVHeaderString</a></div><div class="ttdeci">static int readCSVHeaderString(boost::filesystem::path file, std::vector&lt; std::string &gt; &amp;header)</div><div class="ttdoc">Read header of CSV file into string array. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:409</div></div>
<div class="ttc" id="classIOUtil_html"><div class="ttname"><a href="classIOUtil.html">IOUtil</a></div><div class="ttdoc">I/O utilities. </div><div class="ttdef"><b>Definition:</b> io_util.h:52</div></div>
<div class="ttc" id="classIOUtil_html_a9a6b45f5d8ea7135fb612f50042deab7"><div class="ttname"><a href="classIOUtil.html#a9a6b45f5d8ea7135fb612f50042deab7">IOUtil::getTxtExtensions</a></div><div class="ttdeci">static void getTxtExtensions(std::vector&lt; std::string &gt; &amp;extensions)</div><div class="ttdoc">Gets a vector containing common extensions for text files. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:281</div></div>
<div class="ttc" id="classIOUtil_html_a9a2042854799a9885a77767b359c7b5c"><div class="ttname"><a href="classIOUtil.html#a9a2042854799a9885a77767b359c7b5c">IOUtil::readDirectory</a></div><div class="ttdeci">static void readDirectory(boost::filesystem::path directory, std::vector&lt; std::string &gt; extensions, std::multimap&lt; std::string, boost::filesystem::path &gt; &amp;files, std::string prefix=&quot;&quot;, std::string suffix=&quot;&quot;, std::vector&lt; std::string &gt; exclude=std::vector&lt; std::string &gt;{})</div><div class="ttdoc">Creates an ordered multimap of all files in the given directory. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:205</div></div>
<div class="ttc" id="classIOUtil_html_a46bb84fe3409d74aca7b2e9e2699e35e"><div class="ttname"><a href="classIOUtil.html#a46bb84fe3409d74aca7b2e9e2699e35e">IOUtil::readMat</a></div><div class="ttdeci">static int readMat(boost::filesystem::path file, cv::Mat &amp;mat, std::string field=&quot;mat&quot;)</div><div class="ttdoc">Read an OpenCV matrix. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:42</div></div>
<div class="ttc" id="classIOUtil_html_a301206e86594f7eafa2a561bef4c1eaf"><div class="ttname"><a href="classIOUtil.html#a301206e86594f7eafa2a561bef4c1eaf">IOUtil::readMatCSVFloat</a></div><div class="ttdeci">static int readMatCSVFloat(boost::filesystem::path file, cv::Mat &amp;result)</div><div class="ttdoc">Read CSV file into matrix. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:355</div></div>
<div class="ttc" id="classIOUtil_html_a8fa12c1903f0a602a0cb45748510c9f2"><div class="ttname"><a href="classIOUtil.html#a8fa12c1903f0a602a0cb45748510c9f2">IOUtil::listSubdirectories</a></div><div class="ttdeci">static void listSubdirectories(boost::filesystem::path directory, std::multimap&lt; std::string, boost::filesystem::path &gt; subdirectories)</div><div class="ttdoc">Creates an ordered list of all subdirectories. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:144</div></div>
<div class="ttc" id="classIOUtil_html_a16c52e4be85d55d18d86e2389c8642f0"><div class="ttname"><a href="classIOUtil.html#a16c52e4be85d55d18d86e2389c8642f0">IOUtil::getCSVExtensions</a></div><div class="ttdeci">static void getCSVExtensions(std::vector&lt; std::string &gt; &amp;extensions)</div><div class="ttdoc">Get a vector of common CSV extensions. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:291</div></div>
<div class="ttc" id="classIOUtil_html_ab911811634c83c884c0acbc6b14c1321"><div class="ttname"><a href="classIOUtil.html#ab911811634c83c884c0acbc6b14c1321">IOUtil::writeMatCSV</a></div><div class="ttdeci">static int writeMatCSV(boost::filesystem::path file, const cv::Mat &amp;mat, std::string separator=&quot;,&quot;, int precision=6)</div><div class="ttdoc">Write the content of a cv::Mat to a CSV file. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:107</div></div>
<div class="ttc" id="classIOUtil_html_a9e7c777463186a87bc2cfe24396dba41"><div class="ttname"><a href="classIOUtil.html#a9e7c777463186a87bc2cfe24396dba41">IOUtil::readCSVSummary</a></div><div class="ttdeci">static int readCSVSummary(boost::filesystem::path file, std::vector&lt; std::string &gt; &amp;row_headers, std::vector&lt; std::string &gt; &amp;col_headers, cv::Mat &amp;data)</div><div class="ttdoc">Read a CSV summary file as produced by EvaluationSummary. </div><div class="ttdef"><b>Definition:</b> io_util.cpp:435</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sun Apr 16 2017 16:39:17 for Superpixel Benchmark by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>
